<?php
namespace app\index\service;


use app\index\model\ArchiveModel;
use app\index\model\WageModel;

class HumanService extends CommonService
{

    public function check_archive_name($name, $id=0){
        return !!ArchiveModel::where(['comid'=>$this->userinfo['comid'],'name'=>$name,'deleted_user'=>0])->where('id','neq', $id)->find();
    }

    public function get_arc_tong_state(){
        return ['未签订', '已签订', '终止'];
    }

    public function get_arc_tong_nature(){
        return ['新签', '续签'];
    }


    public function create_wage_number($month){
        $tou = 'GZB';
        $daystr = substr(date("Ym", strtotime($month.'-01')), 2);
        $number = WageModel::where('number','like','%'.$tou.$daystr.'%')->order('number DESC')->value('number');
        if(!$number){
            $str = $tou.$daystr.'00001';
        }else{
            $str = $tou.((int)str_replace($tou,'',$number)+1);
        }
        return $str;
    }

}
